package com.youkeda.wacai.data1.dao;

import com.youkeda.wacai.data1.dataobject.YuruiqiaoRecord;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.type.JdbcType;

public interface YuruiqiaoRecordMapper {
    @Delete({
        "delete from yuruiqiao_record",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into yuruiqiao_record (id, record_type, ",
        "description, amount, ",
        "record_time, category, ",
        "gmt_created, gmt_modified)",
        "values (#{id,jdbcType=INTEGER}, #{recordType,jdbcType=VARCHAR}, ",
        "#{description,jdbcType=VARCHAR}, #{amount,jdbcType=DOUBLE}, ",
        "#{recordTime,jdbcType=TIMESTAMP}, #{category,jdbcType=VARCHAR}, ",
        "#{gmtCreated,jdbcType=TIMESTAMP}, #{gmtModified,jdbcType=TIMESTAMP})"
    })
    int insert(YuruiqiaoRecord record);

    @Select({
        "select",
        "id, record_type, description, amount, record_time, category, gmt_created, gmt_modified",
        "from yuruiqiao_record",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="record_type", property="recordType", jdbcType=JdbcType.VARCHAR),
        @Result(column="description", property="description", jdbcType=JdbcType.VARCHAR),
        @Result(column="amount", property="amount", jdbcType=JdbcType.DOUBLE),
        @Result(column="record_time", property="recordTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="category", property="category", jdbcType=JdbcType.VARCHAR),
        @Result(column="gmt_created", property="gmtCreated", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="gmt_modified", property="gmtModified", jdbcType=JdbcType.TIMESTAMP)
    })
    YuruiqiaoRecord selectByPrimaryKey(Integer id);

    @Select({
        "select",
        "id, record_type, description, amount, record_time, category, gmt_created, gmt_modified",
        "from yuruiqiao_record"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="record_type", property="recordType", jdbcType=JdbcType.VARCHAR),
        @Result(column="description", property="description", jdbcType=JdbcType.VARCHAR),
        @Result(column="amount", property="amount", jdbcType=JdbcType.DOUBLE),
        @Result(column="record_time", property="recordTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="category", property="category", jdbcType=JdbcType.VARCHAR),
        @Result(column="gmt_created", property="gmtCreated", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="gmt_modified", property="gmtModified", jdbcType=JdbcType.TIMESTAMP)
    })
    List<YuruiqiaoRecord> selectAll();

    @Update({
        "update yuruiqiao_record",
        "set record_type = #{recordType,jdbcType=VARCHAR},",
          "description = #{description,jdbcType=VARCHAR},",
          "amount = #{amount,jdbcType=DOUBLE},",
          "record_time = #{recordTime,jdbcType=TIMESTAMP},",
          "category = #{category,jdbcType=VARCHAR},",
          "gmt_created = #{gmtCreated,jdbcType=TIMESTAMP},",
          "gmt_modified = #{gmtModified,jdbcType=TIMESTAMP}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(YuruiqiaoRecord record);
}